package jucTest;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class StreamDemo {
    public static void main(String[] args) {
        User u1 = new User(10, "小新");
        User u2 = new User(12, "小红");
        User u3 = new User(13, "小张");
        User u4 = new User(14, "小刘");
        User u5 = new User(15, "小王");
        List<User> users = Arrays.asList(u1, u2, u3, u4, u5);
        users.stream().filter(new Predicate<User>() {

            @Override
            public boolean test(User o) {
                if (o.getAge() % 2 == 0) {
                    return false;
                }
                return true;
            }
        }).forEach(System.out::println);
    }
}
